package edu.vt.ece4564.bluetendance.classes;

import javax.servlet.http.HttpServletResponse;

import edu.vt.ece4564.bluetendance.database.DatabaseConnector;

public class TeacherRegistrationHandler implements Runnable {
	private String teacherName;
	private String className;
	private HttpServletResponse response;
	
	public TeacherRegistrationHandler(HttpServletResponse response, String teacherName, String className) {
		this.response = response;
		this.teacherName = teacherName;
		this.className = className;
	}
	
	@Override
	public void run() {
		DatabaseConnector dc = DatabaseConnector.get();
		
		dc.commandText = "call SP_RegisterTeacher('" + teacherName + "', '" + className + "');";
		
		dc.executeNonQuery();
		try {
			response.getWriter().write("Your registration information was saved successfully.");
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
